///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once

#ifndef __InstanceBatchHW_VTF_H__
#define __InstanceBatchHW_VTF_H__

#include "OgreInstanceBatchVTF.h"
#include "OgreTexture.h"

namespace Ogre
{
	
	

	
	class _OgreExport InstanceBatchHW_VTF : public BaseInstanceBatchVTF
	{
	protected:
		bool	mKeepStatic;

		//Pointer to the buffer containing the per instance vertex data
		HardwareVertexBufferSharedPtr mInstanceVertexBuffer;

		void setupVertices( const SubMesh* baseSubMesh );
		void setupIndices( const SubMesh* baseSubMesh );

		
		void createVertexSemantics( VertexData *thisVertexData, VertexData *baseVertexData,
			const HWBoneIdxVec &hwBoneIdx, const HWBoneWgtVec& hwBoneWgt );

		
		virtual size_t updateInstanceDataBuffer(bool isFirstTime, Camera* currentCamera);


		virtual bool checkSubMeshCompatibility( const SubMesh* baseSubMesh );

		
		size_t updateVertexTexture( Camera *currentCamera );

		virtual bool matricesToghetherPerRow() const { return true; }
	public:
		InstanceBatchHW_VTF( InstanceManager *creator, MeshPtr &meshReference, const MaterialPtr &material,
							size_t instancesPerBatch, const Mesh::IndexMap *indexToBoneMap,
							const String &batchName );
		virtual ~InstanceBatchHW_VTF();
		
		size_t calculateMaxNumInstances( const SubMesh *baseSubMesh, uint16 flags ) const;

		
		void _boundsDirty(void);

		
		void setStaticAndUpdate( bool bStatic );

		bool isStatic() const { return mKeepStatic; }

		
		virtual void _updateRenderQueue( RenderQueue* queue );
	};

}

#endif
